package com.dragon.refect.bytecode;

/**
 * 方法的动态分派演示
 *
 * @author dragon
 * @since 2019/12/12
 */
public class DynamicDispatch {


    static abstract class Human {

        protected abstract void sayHello();

    }

    static class Man extends Human {

        @Override
        protected void sayHello() {
            System.out.println("hi guy!");
        }

    }

    static class Woman extends Human {

        @Override
        protected void sayHello() {
            System.out.println("hi miss!");
        }
    }

    public static void main(String[] args) {
        Human man = new Man();
        Human woman = new Woman();

        man.sayHello();

        woman.sayHello();

        man = new Woman();

        man.sayHello();
    }
}
